package com.shenzw.common.utils;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

/**
 * @description: 大参林获取rpc-admin-info工具类
 * @author: shenzw
 * @date: 2024/10/31
 */
public class RpcAdminInfoUtils {

    public static void main(String[] args) throws UnsupportedEncodingException {
        String rpcAdminInfo = "{\n" +
                "    \"userId\": 325350660602138624,\n" +
                "    \"tenantId\": 1,\n" +
                "    \"deptId\": 226831180068720643,\n" +
                "    \"name\": \"张柔丹\",\n" +
                "    \"userCode\": \"10151670\",\n" +
                "    \"appId\": \"2\"\n" +
                "}";
        // 编码
        String encode = URLEncoder.encode(rpcAdminInfo, "UTF-8");
        System.out.println(encode);

        // 解码
        String info = "%7B%22userId%22%3A226833809662417626%2C%22tenantId%22%3A1%2C%22deptId%22%3A226831139430109197%2C%20%22name%22%20%3A%20%22%E5%BC%A0%E5%98%89%E4%BC%9F%22%2C%20%22userCode%22%20%3A%20%2210112729%22%2C%20%22appId%22%20%3A%20%222%22%7D";
        System.out.println(URLDecoder.decode(info, "UTF-8"));
    }
}
